package com.hrp.controller;

import com.hrp.domain.Jxkhzq;
import com.hrp.domain.ResponseData;
import com.hrp.service.JxkhzqService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018/8/8 0008.
 */
@RestController
@RequestMapping("jxkhzq")
public class JxkhzqController {


    @Autowired
    private JxkhzqService jxkhzqService;

    @RequestMapping("/getJxkhzqByPage")
    public Map<String,Object> getJxkhzqByPage(Integer page,Integer rows) {
//        Map<String, Object> jsonMap = new HashMap<String, Object>();//定义map
//        List<Jxkhzq> list =  jxkhzqService.getAllKhzq();
//        jsonMap.put("total", list.size());//total键 存放总记录数，必须的
//        jsonMap.put("rows", list);//rows键 存放每页记录 list

        return jxkhzqService.getJxkhzqByPage(page,rows);
    }

    @RequestMapping("/saveKhzqData")
    public ResponseData saveKhzqData(Jxkhzq jxkhzq) {
        try{
            jxkhzqService.saveKhzqData(jxkhzq);
            return ResponseData.ok();
        }catch (Exception e) {
            return ResponseData.build(500, "账期生成失败");
        }
    }

    @RequestMapping("/excutingzq")
    public ResponseData excutingzq(Integer zqid) {
        try{
            jxkhzqService.excutingzq(zqid);
            return ResponseData.ok();
        }catch (Exception e) {
            e.printStackTrace();
            return ResponseData.build(500, "账期生成失败");
        }
    }
}
